//
//  CYGDetailRcmdTableViewController.m
//  CYGHuntForCity
//
//  Created by cygarm on 16/3/23.
//  Copyright © 2016年 cygarm. All rights reserved.
//

#import "CYGDetailRcmdTableViewController.h"
#import "CYGDetailRcmdCellModel.h"
#import "CYGDetailRcmdPicCell.h"
#import "CYGDetailRcmdTextCell.h"
#import "CYGDetailRcmdHeader.h"
#import "CYGDetailRcmdFooter.h"
#import <MJExtension.h>

@interface CYGDetailRcmdTableViewController ()

@end

@implementation CYGDetailRcmdTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];	
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setDatas:(NSArray<CYGDetailRcmdCellModel *> *)datas {
	_datas = [CYGDetailRcmdCellModel mj_objectArrayWithKeyValuesArray:datas];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.datas.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
	CYGDetailRcmdCellModel *cellModel = self.datas[indexPath.row];
	return cellModel.cellHeight;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//	CYGDetailRcmdCell *cell = [[CYGDetailRcmdCell alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 45)];
//	cell.textLabel.text = [NSString stringWithFormat:@"hello-%d", indexPath.row];
//	return cell;

	CYGDetailRcmdCellModel *cellModel = self.datas[indexPath.row];
	if (cellModel.ch) {
		return [CYGDetailRcmdTextCell cellWithTableView:tableView model:cellModel];
	} else {
		return [CYGDetailRcmdPicCell cellWithTableView:tableView model:cellModel];
	}
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
//	DLog(@"scrollView.contentOffset=(%f,%f)", scrollView.contentOffset.x, scrollView.contentOffset.y);
	[self.parent detailRcmdTableViewDidScroll:scrollView.contentOffset];
}

@end
